﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;

public partial class login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
    {
        string name=this.CreateUserWizard1.UserName;
        string password = this.CreateUserWizard1.Password;
        SqlConnection myConn = new SqlConnection("Data Source=127.0.0.1;Initial Catalog=test;User ID=sa;Password=sa123456");
        myConn.Open();

        SqlCommand cmd = new SqlCommand("insert into student(name,password,age) values ('"+name+"','"+password+"','0')");
        cmd.Connection = myConn;
        int i=cmd.ExecuteNonQuery();
        if (i > 0)
        {
            Session["message"] = "创建成功!";
            Response.Redirect("login.aspx");
        }
        else 
        {
            Response.Write("<script>alert('创建失败！');</script>");
            return;
        }
    }
}